module.exports = {
	/**
	 * 修改数据
	 * @url admin/user/sys/update 前端调用的url参数地址
	 * data 请求参数 说明
	 * res 返回参数说明
	 * @params {Number} code 错误码，0表示成功
	 * @params {String} msg 详细信息
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid } = data;
		let res = { code: 0, msg: 'ok' };
		// 业务逻辑开始-----------------------------------------------------------
		// 获取前端传过来的参数
		let {
			_id,
			username,
			password,
			password_secret_version,
			nickname,
			gender,
			status,
			mobile,
			mobile_confirmed,
			email,
			email_confirmed,
			avatar,
			avatar_file,
			department_id,
			role,
			wx_unionid,
			platform,
			tt_openid,
			ks_openid,
			wx_openid,
			dcloud_appid,
			comment,
			third_party,
			register_env,
			realname_auth,
			openid,
			zj_openid,
			had_youhui,
			plus_type,
			plus_expire_time,
			plus_expire_time_str,
			myinviter,
			balance,
			remark,
			score,
			register_date,
			register_ip,
			last_login_date,
			last_login_ip,
			token,
			invite_code,
			inviter_uid,
			finish,
			invite_time,
			my_invite_code,
			clickid,
			tg_pt
		} = data;
		// 参数验证开始
		if (vk.pubfn.isNull(_id)) return { code: -1, msg: 'id不能为空' };
		
		
		// 参数验证结束
		let dbName = "uni-id-users"; // 表名
		// 执行 数据库 updateById 命令
		await vk.baseDao.updateById({
			dbName,
			id:_id,
			dataJson:{
				username,
				password,
				password_secret_version,
				nickname,
				gender,
				status,
				mobile,
				mobile_confirmed,
				email,
				email_confirmed,
				avatar,
				avatar_file,
				department_id,
				role,
				wx_unionid,
				platform,
				tt_openid,
				ks_openid,
				wx_openid,
				dcloud_appid,
				comment,
				third_party,
				register_env,
				realname_auth,
				openid,
				zj_openid,
				had_youhui,
				plus_type,
				plus_expire_time,
				plus_expire_time_str,
				myinviter,
				balance,
				remark,
				score,
				register_date,
				register_ip,
				last_login_date,
				last_login_ip,
				token,
				invite_code,
				inviter_uid,
				finish,
				invite_time,
				my_invite_code,
				clickid,
				tg_pt
			}
		});
		
		let addlog = await db.collection('a_log').add({
			type: "background",
			remark: "后台修改用户id的信息:" + _id,
			op_user: userInfo._id,
			time: new Date().getTime()
		});
		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}

}
